package com.itshi.demo1;

import java.util.Scanner;

/**
 * @author YS
 * @date 2021/7/3
 */
public class test {
    public static int fang(int[] arr){
        int max =arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(max < arr[i]){
                max = arr[i];
            }
        }
        return max;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[10];
        System.out.println("请输入你要查找的数");
        int a = sc.nextInt();
        int sum= -1;
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"个数");
            arr[i] = sc.nextInt();
        }
        for (int i = 0; i < arr.length; i++) {
            if(a == arr[i]){
                sum = i;
            }
        }
        System.out.println("该数在数组中的索引为"+sum);
//        for (int i = 0; i < arr.length; i++) {
//            System.out.println("请输入第"+(i+1)+"个数");
//            arr[i] = sc.nextInt();
//        }
//        for (int i = 0; i < arr.length; i++) {
//            sum += arr[i];
//        }

//        int max = fang(arr);
        System.out.println("数组的和为："+sum);
    }
}
